package com.fmsz.physicalheadline.util;

import android.app.Activity;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.PopupWindow;

import com.fmsz.physicalheadline.R;
import com.fmsz.physicalheadline.databinding.HeadPopupBinding;

/**
 * Created by Administrator on 2017/1/17.
 */

public class CustomPopupWindow implements View.OnClickListener {
    private final View popup;
    private final HeadPopupBinding binding;
    private PopupWindow popupWindow;

    public CustomPopupWindow(View view) {
        binding = DataBindingUtil.inflate(LayoutInflater.from(view.getContext()), R.layout.head_popup, null, false);
        popup = binding.getRoot();
        initView();
    }

    private void initView() {
        popupWindow = new PopupWindow(popup, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
        popupWindow.setTouchable(true);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setAnimationStyle(R.style.share_animate);
        popupWindow.setBackgroundDrawable(new ColorDrawable(0x55000000));
        popupWindow.showAtLocation(popup, Gravity.BOTTOM, 0, 0);
        binding.cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popupWindow.dismiss();
            }
        });
        binding.shareCollect.setOnClickListener(this);
        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
//                context.setTheme(R.style.window_bg);
            }
        });
    }

    @Override
    public void onClick(View v) {

    }
}
